﻿using AntMovement.Core.Enum;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace AntMovement.WPF.Converter
{
    [ValueConversion(typeof(string), typeof(bool))]
    public class DirectionToBoolConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {            
            if (value is bool)
            {
                if (parameter.ToString() == "方向")
                {
                    if ((bool)value == true)
                        return "正向";
                    else
                        return "反向";
                }
                else
                {
                    if ((bool)value == true)
                        return "正极性";
                    else
                        return "负极性";
                }
            }
            return "不存在";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter.ToString() == "方向")
            {
                return value.ToString() == "正向";
            }
            return value.ToString() == "正极性";
        }
    }
}
